<!DOCTYPE html>
<html>
<head>
	<title>授权码</title>
</head>
<body>
<div>
	<span id="code-span"></span>
	<button onclick="getAuthCode()">获取授权码</button>

</div>
</body>
<script type="text/javascript" src="/static/js/jquery-1.11.0.min.js"></script>
<script type="text/javascript">

	function getAuthCode() {
		generateCode().then(data => {
			if (data.res_code == 1) {
				document.getElementById("code-span").innerHTML = data.code
			}
		})		
	}


	function generateCode() {
		return new Promise(resolve => {
			$.ajax({
				type: "post",
				url: "/index.php/Admin/Index/generateAuthCode",
				success: function(res) {
					let data = JSON.parse(res)
					// console.log(data)
					resolve(data)
				}
			})
		})
		
	}
</script>
</html>